package com.test.pattern.iterator;

import java.util.List;

/**
 * @ClassName: StudentIteratorImpl
 * @description:
 * @author: Mr du
 * @create: 2024-03-17 17:45
 */
public class StudentIteratorImpl implements StudentIterator{

    private List<Student> list;
    private int position = 0;

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hashNext() {
        return position < list.size();
    }

    @Override
    public Student next() {
        Student currentStudent = list.get(position);
        position++;
        return currentStudent;
    }
}
